{	Problem: http://codeforces.ru/problemset/problem/48/B
 	Verdict: Accepted
}
uses sysutils;
var i,j,n,m,r,c,x,y,k,t,f,g,d,e:longint; a:array[0..51,0..51] of longint;
begin
read(n,m);
for i:=1 to n do
  for j:=1 to m do read(a[i][j]);
read(x,y);
r:=maxlongint;
k:=n-x+1;
t:=m-y+1;
for i:=1 to k do
  for j:=1 to t do begin
    f:=i+x-1;
    g:=j+y-1;
    c:=0;
    for d:=i to f do
      for e:=j to g do inc(c,a[d][e]);
    if r>c then r:=c;
  end;
k:=n-y+1;
t:=m-x+1;
for i:=1 to k do
  for j:=1 to t do begin
    f:=i+y-1;
    g:=j+x-1;
    c:=0;
    for d:=i to f do
      for e:=j to g do inc(c,a[d][e]);
    if r>c then r:=c;
  end;
write(r);
end.